<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>二手交易平台</title>
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/static/css/main.css">
  <link rel="stylesheet" type="text/css" href="/ssm/consumer/res/layui/css/layui.css">
  <script type="text/javascript" src="/ssm/consumer/res/layui/layui.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <style type="text/css">
  	.userNotLogin{
  		display: none;
  	}
  	.kg-rate-wd-filter-bar {
	    position: relative;
	    padding: 10px;
	    z-index: 1;
	    border: #DDD 1px solid;
	    background: #FCFCFC;
	    color: #404040;
	}
	.kg-rate-wd-filter-bar .filtering {
	    margin-right: 15px;
	    float: left;
	}
	.kg-rate-wd-filter-bar .filtering li {
	    float: left;
	    margin: 2px 10px 2px 0;
	    text-align: left;
	    font-size: 12px;
	}
	.kg-rate-wd-filter-bar .filtering li label {
    cursor: pointer;
	}
	.kg-rate-wd-filter-bar .filtering li {
    float: left;
    margin: 2px 10px 2px 0;
    text-align: left;
    font-size: 12px;
}
	.kg-rate-wd-filter-bar .sorting {
    float: right;
}

.kg-rate-ct-review-item .from-whom .avatar {
    width: 40px;
    height: 40px;
}

.kg-rate-ct-review-item .from-whom {
    float: left;
    overflow: hidden;
    width: 100px;
    text-align: center;
    line-height: 1.5;
}

.kg-rate-ct-review-item {
    position: relative;
    list-style: none;
    outline: 0;
    padding: 10px;
    border-bottom: 1px solid #D4D4D4;
}

.kg-rate-ct-review-item .review-details {
    box-sizing: border-box;
    overflow: hidden;
    margin-left: 100px;
    position: relative;
    zoom: 1;
}

ul {
    list-style: none;
}

 .tb-r-date {
    margin-right: 20px;
    color:#ddd;
}

.tb-tbcr-content {
    font-size: 14px;
    line-height: 1.4;
    color: #3F3F3F;
    word-wrap: break-word;
}

*{padding:0; margin:0;}
li{list-style:none;}
img{border:none;}
.slide{position:relative; width:500px; overflow:hidden;}
.slide .big{ position:relative; overflow:hidden; left:0;top:0;}
.slide a{position:absolute; top:220px; opacity:0;z-index:1000;}
.slide .big li{float:left; width:500px;}
.slide .big  li img{width:100%;display:block;}
.slide .prev{left:-10px;}
.slide .next{right:-10px;}
.slide .small{ margin-top:5px; width:100%; position:relative;}
.slide .small li{ float:left;margin-right:5px; width:121px; background:#000;}
.slide .small li:last-child{ margin-right:0;}
.slide .small li img{width:100%;display:block; opacity:0.5;}
#description img{ width:100%; }
  </style>
  <script src="js/single_lb.js"></script>
	<script src="js/move1.js"></script>
</head>
<body>

  <div class="site-nav-bg">
    <div class="site-nav w1200">
      <p class="sn-back-home">
        <i class="layui-icon layui-icon-home"></i>
        <a href="/ssm/consumer/index.html">首页</a>
      </p>
       <div class="sn-quick-menu">
        	<div class="userLogin">
        		<div class="login"><a href="/ssm/consumer/login.html">登录</a></div>
        		<div class="login"><a href="/ssm/consumer/register.html">注册</a></div>
        	</div>
        	<div class="userNotLogin">
        		<div class="login"><a href="/ssm/consumer/userInfo.html" id="username">用户名</a></div>
        		<div class="login"><a href="JavaScript:loginOut();">退出</a></div>
        		<div class="login"><a href="/ssm/consumer/myOrder.html">我的订单</a></div>
        		<div class="sp-cart"><a href="/ssm/consumer/shopcart.html">购物车</a></div>
        	</div>
      </div>
    </div>
  </div>



  <div class="header">
    <div class="headerLayout w1200">
      <div class="headerCon">
        <h1 class="mallLogo">
          <a href="/ssm/consumer/index.html" title="二手交易平台">
            <img src="/ssm/consumer/res/static/img/logo.png">
          </a>
        </h1>
        <div class="mallSearch">
           <form action="" class="layui-form" novalidate>
            <input type="text" id="keyword" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入需要的商品">
            <button class="layui-btn" id="searchbutton" lay-filter="formDemo" onclick="return false">
                <i class="layui-icon layui-icon-search"></i>
            </button>
            <input type="hidden" name="" value="">
          </form>
        </div>
      </div>
    </div>
  </div>


  <div class="content content-nav-base datails-content">
    <div class="main-nav">
      <div class="inner-cont0">
        <div class="inner-cont1 w1200">
          <div class="inner-cont2">
            <a href="#" class="active">商品详情</a>
          </div>
        </div>
      </div>
    </div>
    <div class="data-cont-wrap w1200">
      <div class="crumb">
        <a href="javascript:;">首页</a>
        <span>></span>
        <a href="javascript:;">所有商品</a>
        <span>></span>
        <a href="javascript:;">产品详情</a>
      </div>
      <div class="product-intro layui-clear" style="float: left;overflow:hidden;">
       	<div class="slide" id="single_lb">
			<a href="javascript:;" class="prev"><img src="images2/prev.png"></a>
		    <a href="javascript:;" class="next"><img src="images2/next.png"></a>
			 <ul class="big" style="height:310px">
		    </ul>
		    <ol class="small" style="display:none;">
		    </ol>
		</div>
       	 <div class="layui-clear">
	      	<div style="margin-top: 40px;width:220px;height:300px;;background-color: #f6f6f6;float: left;">
	        		<h3 style="text-align: center;line-height: 30px;">卖家信息</h3>
	        		<hr>
	        		<div style="text-align: center;margin-left: 80px;">
	        			<img src="https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3187703603,4093680061&fm=26&gp=0.jpg" style="display: block; left: 265.114px; top: -10px; width: 63.75px; height: 60px;vertical-align: middle;border: 1px solid #ccc;border-radius: 30px;"/>
	        		</div>
	        		<div style="text-align: center;margin-left: -30px;">
	        			 <p class="address-box" style="    line-height: 40px;
	    padding-left: 34px;text-align:center;
	    color: #888888;"><span>店铺成交量： </span><strong id="company_buynum">暂无记录</strong> </p>
	               <p class="address-box" style="    line-height: 40px;
	    padding-left: 34px;text-align:center;
	    color: #888888;"><span>消费好评度：</span><strong id="company_score">暂无记录</strong> </p>
	    
	     <p class="address-box" style="    line-height: 40px;
	    padding-left: 34px;text-align:center;
	    color: #888888;"><a style="color: blue;" id="goCompany" href="companyProduct.html">进入店铺</a> </p>
	        		</div>
	       	</div>
	      </div>
       </div>
       <div class="itemInfo-wrap" style="float: right;width: 670px;">
         <div class="itemInfo">
           <div class="title">
             <h4 id="pname"> </h4>
           </div>
           <div class="summary">
             <p class="reference"><span>市场价</span> <del id="markprice">￥280.00</del></p>
             <p class="activity"><span>商城价</span><strong class="price" id="estoreprice"><i>￥</i>99.00</strong></p>
             <p class="address-box"><span>剩余库存</span><strong id="pnum"></strong> </p>
              <p class="address-box"><span>成交量</span><strong id="buynum"></strong> </p>
           </div>
           <div class="choose-btns">
             <button id="buy" class="layui-btn layui-btn-primary purchase-btn">立刻购买</button>
             <button id="addToCar" class="layui-btn  layui-btn-danger car-btn"><i class="layui-icon layui-icon-cart-simple"></i>加入购物车</button>  
           </div>
         </div>
          	<div class="detail" style="margin-top: 40px;width: 140%;">
	          <h4 style="width:auto;text-align: left;">
	          <a href="#item1">&nbsp;&nbsp;详&nbsp;情&nbsp;&nbsp;</a>|
	          <a href="#item2">&nbsp;&nbsp;评&nbsp;论&nbsp;&nbsp;</a>|
	          <a href="#item3">&nbsp;&nbsp;问&nbsp;店&nbsp;家&nbsp;&nbsp;</a></h4>
	        </div>
          	<div class="detail" id="item1" style="margin-top: 10px;width: 140%;">
	          <h4 >宝贝详情</h4>
	          <div class="item" id="description" style="float: right;width: 100%;">
	           
	          </div>
	        </div>
	        
	        <div class="detail" id="item2" style="margin-top: 10px;width: 140%;">
	          <h4>评论列表</h4>
	          <div class="item"  style="float: right;width: 100%">
	           	<div class="kg-rate-main">
    
    <div class="kg-rate-detail">
      <div class="J_KgRate_Main">
        <div class="J_KgRate_MainReviews" data-kg-rate-tab="reviews">
          <div class="tb-revhd">
            
            
            <div class="kg-rate-wd-filter-bar" style=" height: 20px;line-height: 20px;">
              <ul class="J_KgRate_Filter filtering">
                <li class="is-current">
                  <label for="reviews-t-all" data-spm-anchor-id="2013.1.0.i3.357520bapWScUr">
                    <input type="radio" name="J_KgRate_ReviewType" id="reviews-t-all" value="" checked="">
                   		全部
                  </label>
                </li>
              </ul>
              
            </div>
          </div>
          <div class="tb-revbd">
<ul id="orderList">
  
  
</ul>

<div class="kg-pagination2 thm-1 align-r">
  
</div></div>
        </div>
      </div>
    </div>
  </div>
	          </div>
	        </div>
	        <div class="detail" id="item3" style="margin-top: 10px;width: 140%;">
									<div class="pageRight-deptList">
										<div class="deptList-block mb20 clearfix">
											<div id="branchHisDept100201"
												style=" margin-bottom: 40px;"></div>
											<hr />
											<h4>问店家</h4>
											<div id="commentList"></div>
											<hr />
											<div>
												<textarea id="content" rows="" cols=""
													style="width: 140%; height: 100px;"></textarea>
												<br/>
												<button id="submit" style="background: #3189d3; border: none; height: 40px; font-size: 14px; color: #fff; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;">发表评论</button>
											</div>
										</div>
									</div>
								</div>
	        
        </div>
      </div>
    </div>
  </div>
<script type="text/javascript">
  layui.config({
    base: '/ssm/consumer/res/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
  }).use(['mm','jquery'],function(){
      var mm = layui.mm,$ = layui.$;
      var cur = $('.number-cont input').val();
      $('.number-cont .btn').on('click',function(){
        if($(this).hasClass('add')){
          cur++;
         
        }else{
          if(cur > 1){
            cur--;
          }  
        }
        $('.number-cont input').val(cur)
      })
      
   	$("#searchbutton").click(function Search(){
		location.href="/ssm/consumer/index.html?pname="+$("#keyword").val();
		return false;
	})
	
	var info;
    getUserInfo();
    function  getUserInfo(){
        $.ajax({
            url:"/ssm/consumer/loginInfo.do",
            type:"POST",
            dataType:"json",
            success:function(data){
            	info = data.body
               if(info!=null){
            	   $(".userLogin").hide();
            	   $("#username").text(info.real_name);
            	   $(".userNotLogin").show();
               }else{
            	   $("#submit").text("请先登录");
               		$("#submit").attr("disabled","disabled");
               }
            } 
        })
     }
    
    
    getProductDetail();
	function getProductDetail(){
		var postData = {
				page:1,
				limit:100,
				status:1,
				pid:getQueryString("pid"),
		}
		$.post('/ssm/product/queryList.do',postData,function(data){
			console.log(data);
			for(var idx in data.body.list){
				var productItem = data.body.list[idx];
				$("#imgUrl").attr('src',);
				var imgs = productItem.imgurl.split(",");
				for(var idx in imgs){
					if(imgs[idx]){
						$(".big").append(' <li><img src="'+imgs[idx]+'"/></li>');
						if(idx==0){
							$(".small").append(' <li><img style="opacity:1" src="'+imgs[idx]+'"/></li>');
						}else{
							$(".small").append(' <li><img src="'+imgs[idx]+'"/></li>');
						}
					}					
				}
				single_lb();
				$("#description").html(productItem.description);
				$("#pname").text(productItem.pname);
				$("#estoreprice").text(productItem.estoreprice);
				$("#markprice").text(productItem.markprice);
				$("#cname").text(productItem.cname);
				$("#pnum").text(productItem.pnum);
				$("#buynum").text(productItem.buynum);
				queryCompany(productItem.consumer_id);
			}
			
		})
	}
      
	
	function getQueryString(name) {
	    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	    var r = window.location.search.substr(1).match(reg);
	    if (r != null) return decodeURI(r[2]); return null;
	} 
	
	$("#addToCar").click(function(){
		addCart();
	})
	
	$("#buy").click(function(){
		buy();
	})
	
	function addCart(){
		if(!info){
			location.href="/ssm/consumer/login.html";
			return;
		}
		var postData = {
				pid:getQueryString("pid"),
				pnum:1,
		}
		$.post('/ssm/car/save.do',postData,function(data){
			alert('添加成功');		
		})
	}
	
	function buy(){
		if(!info){
			location.href="/ssm/consumer/login.html";
			return;
		}
		var postData={
      		  pids:getQueryString("pid"),
      		  pNumbers:1
        }
        $.post('/ssm/order/placeOrderPrev.do',postData,function(data){
      	  location.href="/ssm/consumer/placeOrder.html";
        })
		
	}
	
	function queryCompany(consumerId){
		  var postData={
				  consumerId:consumerId,
	        }
	        $.post('/ssm/order/queryCompany.do',postData,function(data){
	      	  	if(data.body){
	      	  	$("#company_buynum").text(data.body.buynum);
	      		$("#company_score").text(data.body.socre);
	      		$("#goCompany").attr('href','/ssm/consumer/companyProduct.html?id='+consumerId)
	      	  	}
	        })
		  
	  }
	
	 queryProductComment();
		function queryProductComment(){
			var postData = {
					page:1,
					limit:100,
					status:1,
					pid:getQueryString("pid"),
			}
			$.post('/ssm/order/queryProductComment.do',postData,function(data){
				console.log(data);
				for(var idx in data.body){
					var productItem = data.body[idx];
					var item = '<li id="review-1063714526825" class="J_KgRate_ReviewItem kg-rate-ct-review-item" tabindex="0">';
					item+='<div class="from-whom">';
					item+=' <img class="avatar" src="//img.alicdn.com/tps/i3/TB1yeWeIFXXXXX5XFXXuAZJYXXX-210-210.png">';
					item+='</div>';
					item+='<div class="review-details">';
					item+='<div class="tb-rev-item " data-id="1063714526825">';
					item+='<div class="J_KgRate_ReviewContent tb-tbcr-content ">';
					item+=''+productItem.cellphone+':'+productItem.comment;
					item+='</div>';
					item+='<div class="tb-r-act-bar">';
					item+='<div class="tb-r-info">';
					item+='<span class="tb-r-date">'+productItem.comment_time+'</span>';
					item+='</div>';
					item+='</div>';
					item+='</div>';
					item+='</div>';
					item+='</li>';
					$("#orderList").append(item);
				}
				
			})
		}
		
		$("#submit").click(function(){
			var content = $("#content").val();
			if(content.length>0){
				var postData = {
						content:content,
						product_id:getQueryString('pid'),
						type:'c'
				}
				$.post('/ssm/productComment/cud.do',postData,function(data){
					location.reload();
				})
				
			}else{
				alert("请先说点什么吧");
				
			}
		})
		
		loadCommentList();
		function loadCommentList(){
			var postData = {
					pid:getQueryString('pid')
			}
			$.post('/ssm/productComment/r.do',postData,function(res){
		        console.log(res);
		        data= res.body.list;
		        for(var idx in data){
		        	var item='<hr /><div class="mb20 clearfix pl20">';
		        	item+='<div class="authi" style="line-height:25px;">';
		        	item+='<p id="authorposton95865">'+data[idx].username+'：发表于 '+data[idx].create_date+'</p>';
		        	item+='<span class="pipe"></span>';
		        	item+='</div>';
		        	item+='<div style="height:auto;font-size:18px;line-height:35px;">'+data[idx].content+'</div>';
		        	if(data[idx].reply){
		        		item+='<div style="height:auto;font-size:18px;line-height:35px;">店家回复：'+data[idx].reply+'</div>';
		        	}
		       		item+='</div>';
		        	$("#commentList").append(item);
		        }
		        
		    })
			
		}
  });
  
    
  
</script>


</body>
</html>